var reg1 = /http/
var reg2 = new RegExp("http")
    //reg1和reg2是等效的
var reg3 = /http:\/\//
var reg4 = new RegExp("http://");
//reg3和reg4是等效的
var reg5 = /http/i;

var mStr = `abc
http://baidu.com
end`
var mStr1 = "start\n\rhttp://baidu.com\n\rend"

var str1 = "abcdeafdvaefafdaaaddae"
    //查找字符串里面的子字符串输入
function countSubStr(str, sub) {
    var count = 0;
    for (var i = 0; i < str.length; i++) {
        var s = '';
        for (var j = 0; j < sub.length; j++) {
            s += str[i + j]
        }
        if (s == sub) {
            count++
        }
    }
    return count
}

function countSubStr1(str, sub) {
    var count = 0;
    var reg = new RegExp(sub, "g");
    while (reg.test(str)) {
        count++
    }
    return count
}

function countSubStr2(str, sub) {
    var reg = new RegExp(sub, "g");
    var resArray = str.match(reg);
    return resArray.length

}